package FactoryMethod.exp.idcard;

import FactoryMethod.exp.framework.Factory;
import FactoryMethod.exp.framework.Product;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zsh
 * @Description
 * @create 2022-05-11 20:28
 */
public class IDCardFactory extends Factory {

    private List<String> owners = new ArrayList<>();
    private Map<String, String> owner_id = new HashMap<>();


    @Override
    protected void registerProduct(Product product) {
        String owner = ((IDCard) product).getOwner();
        String id = ((IDCard) product).getId();
        owners.add(owner);
        owner_id.put(owner,id);
    }

    @Override
    protected Product createProduct(String owner) {
        return new IDCard(owner);
    }

    public List<String> getOwners(){
        return owners;
    }

    public Map<String, String> getOwnerIds(){
        return owner_id;
    }
}
